#ifndef _SERIALDRIVER
# define _SERIALDRIVER
# include "Serial.h"

//宏定义
# define PI 3.14159f
# define Tesla2Gauss 1.0f
# define MPU9250M_4800uT   ((float)0.6f)            // 0.6 uT/LSB
# define GRAVITY_MSS 9.80267f

# define calibrate_cnt_total 100

// float mag_offset[3]={-71.4387,-37.9589,111.7972};
// float mag_sca[9]={0.9824,-0.0149,0.0120,-0.0149,0.9845,0.0219,0.0120,0.0219,0.9445};
# define GRAVITY_MSS 9.80267f

//定义数据类型
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef short int16;

# define UserGyrResolution ((float) 0.007633587786f)
# define MPU9250A_4g ((float)0.000122070312f)
//#define Gravity_g 10
# define Byte16(Type, ByteH, ByteL) (Type)(((uint16)(ByteH)<<8)|((uint16)(ByteL)))

class serialdriver
{
public:
    serialdriver();
    ~serialdriver();
    bool processdata(uint8 * dataPacket, double * databuff);  
    bool iscalibrated(){return _iscalibrated;}
    bool readdata();
    bool getreadstatus(){return _readok;}
    double* getprocesseddata(){return _processeddata;}
private:
    bool _iscalibrated;
    int _calibrate_cnt;
    bool _readok;
    SerialHandler* _mserial;
    double* _processeddata;
    double _xbias, _ybais, _zbias;
};

#endif